WDV221 Intro Javascript

Variables and Data Types - String Object Assignment


Please complete the following exercises on this page. When complete post this page to your server. Make a link in your WDV221 homework page for this assignment.

Include a comment in each script with the exercise number and a description of what the script is supposed to do.

Using Blackboard submit this Assignment.

For each exercise use a comment line to put the Exercise number within the script. Also place a short description of what the script is doing.


1. Define a global variable called inName. Assign it an initial value of "".

2. Create a function called getName( ). The function will use a prompt to ask the user to enter a name. Store the result in the inName variable. Use an event handler to activate this function.

3. Create a function called displayName( ). The function will use alert( ) to display the value stored in the inName variable. It will also display the number of characters in the inName variable. Use and event handler to activate this function.

Define a global variable called emailAddress. Assign it an email address. Define a global variable called yourEmailAddress and assign it the value of your DMACC email address.

Create a function called getEmailName( ). This function will accept one input parameter. When the function is called display only the name from the email address. For example if the user enters "jLeenan@yahoo.com" your function should display "jLeenan". Use an event handler to activate this function.

4. Use the getEmailName( ) function to process emailAddress.

5. Use the getEmailName( ) function to process yourEmailAddress.